package adapters;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;


import com.metodo_ahp.usuario.aplicacionmetodoahp.R;

import java.util.List;

import libreria.WizardStep;
import modelo.Item;

/**
 * Created by Usuario on 28/09/2014.
 */
public class AlternativaDefinicionAdapter extends ArrayAdapter {
    Activity context;
    private List<Item> alternativas;

    static class ViewHolder {
        public EditText text;
    }

    public AlternativaDefinicionAdapter(WizardStep context, List<Item> datos){
        super(context.getActivity(), R.layout.step_3_item_def_alternativa,datos);
        this.context= context.getActivity();
        this.alternativas = datos;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View item = convertView;

        if(item == null)
        {
            LayoutInflater inflater = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            item = inflater.inflate(R.layout.step_1_item_def_criterio, parent, false);
            //Configurar view holder.
            ViewHolder holder = new ViewHolder();
            holder.text = (EditText) item.findViewById(R.id.txtDefAlternativaNombre);

            item.setTag(holder);
        }

        //Fill data.
        ViewHolder holder = (ViewHolder) item.getTag();
        holder.text.setText(alternativas.get(position).getNombre());

        return item;
    }
}
